package offer;

import java.util.ArrayList;
import java.util.List;

public class offer54 {
}
class Solution54 {
    List<Integer> list = new ArrayList<>();
    public int kthLargest(TreeNode root, int k) {
        if(root==null) return 0;
        traverse(root,list);
        int index = list.size()-k;

        return list.get(index);
    }

    private void traverse(TreeNode root, List<Integer> list) {
        if(root==null) return;
        traverse(root.left,list);
        list.add(root.val);
        traverse(root.right,list);
    }
}